﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WeiXinPF.Common;
using WeiXinPF.Templates;

namespace WeiXinPF.Web.modules.cdrt.smart
{
    public partial class scenic : TBasePage
    {
        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);
            if (!string.IsNullOrEmpty(errInitTemplates))
            {
                Response.Write(errInitTemplates);
                return;
            }

            /*
            BLL.wx_templates tBll = new BLL.wx_templates();
            templateIndexFileName = tBll.GetTemplatesFileNameByWid(wid);
            if (string.IsNullOrEmpty(templateIndexFileName))
            {
                errInitTemplates = "不存在该帐号或者该帐号尚未设置模版！";
                Response.Write(errInitTemplates);
                Response.End();
                return;
            }
            */

            var requestOpenId = MyCommFun.RequestOpenid();
            if (MyCommFun.IsEmptyOpenId(requestOpenId))
            {
#if DEBUG
                requestOpenId = ConfigurationHelper.GetDebugOpenId();
#else
                //var thisUrl = MyCommFun.getWebSite() + "/modules/cdrt/smart/message.aspx?wid=" + wid;
                //var bll = new BLL.wx_userweixin();
                //var uWeiXinModel = bll.GetModel(wid);
                //base.OAuth2BaseProc(uWeiXinModel, "message", thisUrl);
#endif
            }

            var scenicId = MyCommFun.RequestInt("aid");

            tPath = MyCommFun.GetRootPath() + "/modules/cdrt/smart/templates/scenic.html";
            TemplateMgr template = new TemplateMgr(tPath, wid);
            template.tType = TemplateType.ScenicDetail;
            template.ExtraValue = scenicId.ToString();
            template.openid = requestOpenId;
            template.OutPutHtml(templateIndexFileName, wid);
        }
    }
}